Skip to content
This repository was archived by the owner on Oct 3, 2019. It is now read-only.

create imagestreams and buildconfig for nodejs runtime - #13

Merged
corinnekrych merged 13 commits into
redhat-developer:masterfrom
corinnekrych:odc-131
Mar 7, 2019
Merged

corinnekrych merged 13 commits into
redhat-developer:masterfrom
corinnekrych:odc-131

Conversation

@corinnekrych

Copy link
Copy Markdown
Contributor

shortNames:
- gitsrc
scope: Namespaced
validation:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing validation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry @alexeykazakov side effect of operator-sdk generate openapi of operator-sdk 0.5.0
I've removed it from makefile's build command.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type ComponentSpec struct {
// Container image use to build (nodejs, golang etc..)
BuildType string `json:"buildType"`
Codebase string `json:"codebase"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is Codebase? Git URL?
Could you please add a description?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// IsController: true,
// OwnerType: &componentsv1alpha1.Component{},
//})
if err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// Create an empty image name "nodejs-runtime"
newImageForRuntime := newImageStreamFromDocker(instance.Namespace, instance.Name, instance.Spec.BuildType)
err = r.client.Create(context.TODO(), newImageForRuntime)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newImageForRuntime could be nil. Should it be handled?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes indeed
870bc31

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@corinnekrych, the fix could still cause problems.
Can you please split the if err != nil || newImageForRuntime == nil { line two two seperate If checks?
That would allow us to have different error logging in both the cases.

}

var _ reconcile.Reconciler = &ReconcileComponent{}
var buildTyppeImages = map[string]string{"nodejs":"nodeshift/centos7-s2i-nodejs:10.x"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: we would use builder images present in the openshift namespace. So, this list could be constructed out of the builder images present in oc get imagestreams -n openshift

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed!
but some imagestream (for ex: golang) are missing from openshift namespace, so building from ext docker image could still be useful.
I need to investigate further how to reuse those imagestream from another project, it work fine if i search for then within openshift project but coudn't find then from outside.
Let me track this in subtask https://jira.coreos.com/browse/ODC-133

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a small typo too

Suggested change
var buildTyppeImages = map[string]string{"nodejs":"nodeshift/centos7-s2i-nodejs:10.x"}
var buildTypeImages = map[string]string{"nodejs":"nodeshift/centos7-s2i-nodejs:10.x"}

@jarifibrahim jarifibrahim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks good to me. Just a few minor things and then we can merge it. Thanks for fixing the docs and Readme @corinnekrych 🎉

Comment thread cmd/manager/main.go Outdated

log.Info("Registering Components.")

// Setup Scheme for all resources

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be removed :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spec:
properties:
buildType:
type: string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we would have a limited number of buildTypes, I think we should add the enum here. See https://github.com/operator-framework/operator-lifecycle-manager/blob/master/deploy/upstream/quickstart/olm.yaml#L1011 for an example.

What do you think @corinnekrych

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5046adb
for now only added nodejs, more will be added as we progress

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good 👍

singular: gitsource
shortNames:
- gitsrc
- gitsrc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be indented :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

var _ reconcile.Reconciler = &ReconcileComponent{}
var buildTyppeImages = map[string]string{"nodejs":"nodeshift/centos7-s2i-nodejs:10.x"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a small typo too

Suggested change
var buildTyppeImages = map[string]string{"nodejs":"nodeshift/centos7-s2i-nodejs:10.x"}
var buildTypeImages = map[string]string{"nodejs":"nodeshift/centos7-s2i-nodejs:10.x"}


// Create an empty image name "nodejs-runtime"
newImageForRuntime := newImageStreamFromDocker(instance.Namespace, instance.Name, instance.Spec.BuildType)
err = r.client.Create(context.TODO(), newImageForRuntime)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@corinnekrych, the fix could still cause problems.
Can you please split the if err != nil || newImageForRuntime == nil { line two two seperate If checks?
That would allow us to have different error logging in both the cases.

log.Error(err, "** Creating new RUNTIME image fails **")
return reconcile.Result{}, err
}
if newImageForRuntime == nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant check. We can move this check to line 133.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return reconcile.Result{}, err
}

log.Info("** Build config created **")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message seems to be off. We have not yet created a build config, have we?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@corinnekrych

Copy link
Copy Markdown
Contributor Author

@jarifibrahim I've integrated all you comment and cleared the todo
@sbose78 is it good to go?

@jarifibrahim jarifibrahim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 💯

@corinnekrych
corinnekrych merged commit c976e72 into redhat-developer:master Mar 7, 2019
@alexeykazakov

Copy link
Copy Markdown
Member

I don't see any tests for this code.

@corinnekrych

Copy link
Copy Markdown
Contributor Author

Coming see odc-98 for the whole user story

@bartoszmajsak

Copy link
Copy Markdown

I don't see any tests for this code.

@sbose78 did we forget to add @alien-ike bot to this repo? ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants